package cn.cons;

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.TreeSet;

/**
 * description:
 * author:zcx
 * lenovo
 * 时间：2022.02.12.11.05
 */
public class C2 {
    public static void main(String[] args) {
       hashset();
       //treeset();
       int a=10;
       int b=10;
        a=a + ++a;//20
        //int i=a++ + a;
        //System.out.println(a);
        //System.out.println(i);
        //Linkedhashset();

    }
    private static void Linkedhashset(){
        LinkedHashSet<Cat> linkedHashSet=new LinkedHashSet<>();
        Cat c1=new Cat("白猫",2);
        Cat c2=new Cat("花猫",1);
        Cat c3=new Cat("黑猫",2);
        linkedHashSet.add(c1);
        linkedHashSet.add(c2);
        linkedHashSet.add(c3);
        for (Cat s:linkedHashSet) {
           if( s.getName().contains("白猫")){
               System.out.println(s);
           }
        }
    }
    private static void treeset(){
        TreeSet<Cat> set=new TreeSet<>(new CatComparator());
        Cat c1=new Cat("咖啡猫",1);
        Cat c2=new Cat("咖猫",5);
        Cat c3=new Cat("咖防火猫",3);
        set.add(c1);
        set.add(c2);
        set.add(c3);
        System.out.println(Arrays.stream(set.toArray()).toList());
        for ( Cat s:set) {
            System.out.println(s.toString());
        }

    }
    private static void hashset(){
//        HashSet<String> hashSet=new HashSet<>();
//        hashSet.add("的功夫的");
//        hashSet.add("对方的");
//        System.out.println(hashSet.size());
//        for (String name:hashSet){
//            System.out.println(name);
//        }
//        System.out.println(Arrays.stream(hashSet.toArray()).toList());
        HashSet<Cat> set=new HashSet<>();
       Cat c1=new Cat("白猫",3);
        Cat c2=new Cat("h黑猫",6);
        Cat c3=new Cat("白猫",3);
        set.add(c1);
        set.add(c2);
        set.add(c3);
        for (Cat s1:set) {
            System.out.println(s1);
        }
        System.out.println(c1.hashCode());
        System.out.println(c2.hashCode());
        System.out.println(c3.hashCode());
    }
}
